{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}Mapping
{% endblock %}

{% block content %}
<form action="/web_mapping_post" method="post" id="postattr" name="postattr" class="form-inline">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
    <div class="form-row align-items-center">

        <div class="form-group col-md-offset-0">
            <label>数据库</label>
            <select id="db" name="db" class="form-control" onchange="read_table_by_db_js(this.options[this.options.selectedIndex].value, '{{ csrf_token() }}')">
                <option value="0">--数据库--</option>
                {% if db_data %}
                    {% for foo in db_data %}
                        <option value="{{ foo.id }}">{{ foo.db_name }}</option>
                    {% endfor %}
                {% endif %}
            </select>
        </div>

        <div class="form-group col-md-offset-0">
            <label>表</label>
            <select id="table" name="table" class="form-control" ></select>
        </div>

    </div><br>
    <input type="submit" value="提交" />
</form>
<br>


<form action="/web_mapping_post_post?db_id={{ db_id }}&table_id={{ table_id }}" method="post" id="mapping_post" name="mapping_post">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
    {% if json_data %}
        {% for i in json_data %}
            <div class="form-inline">
                <label class="form col-md-1">{{ i.get('column_name') }}</label>
                <input class="form col-md-11" type="text" name="{{ i.get('id') }}" placeholder="db1.table1.column1;db2.table2.column3(注意连接符为.，分隔符为;)">
                <br><br>
            </div>

        {% endfor %}
    <input type="submit" value="提交" />
    {% endif %}
</form>
{% endblock %}

{% block scripts  %}
{{ super() }}
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="/static/js/my_test.js"></script>
{% endblock %}
